<%@ page import="java.util.Calendar" %>
<%@ page import="java.util.GregorianCalendar" %>
<%@ page import="com.sun.org.apache.bcel.internal.generic.IF_ACMPEQ" %>
<%--
  Created by IntelliJ IDEA.
  User: 黑白客
  Date: 2019/6/1
  Time: 18:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>这个例子使用了setIntHeader()方法来设置刷新头，
        模拟一个数字时钟</title>
</head>
<body>
    <h2>自动刷新实例</h2>
    <%
        //设置每隔5秒自动刷新一次
        response.setIntHeader("Refresh",5);
        //获取当前时间
        Calendar calendar = new GregorianCalendar();
        String am_pm;
        int hour = calendar.get(Calendar.HOUR);
        int minute = calendar.get(Calendar.MINUTE);
        int second = calendar.get(Calendar.SECOND);
        if (calendar.get(Calendar.AM_PM) == 0 ){
            am_pm = "AM";
        }else{
            am_pm = "PM";
        }
        String CT = hour + ";" + minute + ":" + second + "  "
        + am_pm ;
        out.print("当前时间：" + CT + "\n");
    %>
</body>
</html>
